#include "networksettings.h"
#include "ui_networksettings.h"

networksettings::networksettings(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::networksettings)
{
    ui->setupUi(this);
}

networksettings::~networksettings()
{
    delete ui;
}

char * networksettings::StringToCharArr(string str) {
    char* arr = new char[str.length()];
    for (int i = 0; i < str.length(); i++) {
        arr[i] = str.at(i);
    }
    return arr;
}

void networksettings::on_buttonBox_accepted() {
    IPAddr = ui->Txt_IP->text().toStdString();
    Port = atoi(StringToCharArr(ui->Txt_Port->text().toStdString()));
    YourName = ui->Txt_UserName->text().toStdString();
    isServer = ui->checkBox_Server->isChecked();
    qDebug() << "server mode enable: " << isServer;
}

void networksettings::on_buttonBox_rejected() {
    qDebug() << "networksettings cancel";
}

void networksettings::on_buttonBox_helpRequested() {
    // nothing to do...
}
